package listbyorder.access201_300.test240;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/27 11:07
 */
public class Solution1 {

    public boolean searchMatrix(int[][] matrix, int target) {
        if (matrix == null || matrix.length == 0 || matrix[0].length == 0) return false;
        int r = matrix.length - 1;
        int cow = matrix[0].length;
        int c = 0;
        while (r >= 0 && c < cow) {
            if (matrix[r][c] == target) {
                return true;
            }
            if (matrix[r][c] > target) {
                r--;
            } else {
                c++;
            }
        }
        return false;
    }
}
